;(function () {
	var docEl = document.documentElement
	var viewportEl = document.querySelector('meta[name="viewport"]'),
		dpr = window.devicePixelRatio || 1,
		maxWidth = 540,
		minWidth = 320
	dpr = dpr >= 3 ? 3 : dpr >= 2 ? 2 : 1
	var scale = 1 / dpr
	var content = `width=device-width, initial-scale=${scale}, user-scalable=no, maximun-scale=${scale},minimun-scal=${scale}`
	if (viewportEl) {
		viewportEl.setAttribute("content", content)
	} else {
		viewportEl = document.createElement("meta")
		viewportEl.setAttribute("name", "viewport")
		viewportEl.setAttribute("content", content)
		document.head.appendChild(viewportEl)
	}
	docEl.setAttribute("self-dpr", dpr)
	docEl.setAttribute("max-width", maxWidth)
	docEl.setAttribute("min-width", minWidth)

	setRootFontSize()
	window.addEventListener("resize", setRootFontSize)
	function setRootFontSize() {
		var ratio = 18.75
		var docEl = document.documentElement
		var viewWidth = docEl.getBoundingClientRect().width || window.innerWidth
		//限制fontSize:使内容不会无限制放大缩小
		if (maxWidth && viewWidth / dpr > maxWidth) {
			viewWidth = maxWidth * dpr
		} else if (minWidth && viewWidth / dpr < minWidth) {
			viewWidth = minWidth * dpr
		}

		docEl.style.fontSize = viewWidth / ratio + "px"
	}
})()
